<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<script charset="utf-8" src="jslib/kindeditor/kindeditor-min.js"></script>
<script type="text/javascript">
var editor;
$(function() {
	KindEditor.basePath = 'jslib/kindeditor/';
	editor = KindEditor.create('#moduls_fun_editPersDuty_editForm textarea[name=pdCont]',{
		afterChange: function (e) { this.sync(); },
		wellFormatMode : false,
		items : [
			'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
			'removeformat']
	});

	$("#moduls_fun_editPersDuty_editForm #userId").combogrid({
		url : '${pageContext.request.contextPath}/userAction!queryUser.action',
		loadMsg : '数据加载中....',
		missingMessage : '请检索用户名',
		panelWidth : 440,
		panelHeight : 180,
		delay : 500,
		fitColumns : true,
		value : '',
		idField : 'userId',
		textField : 'userRealName',
		mode : 'remote',
		pagination : true,
		missingMessage:'请检索用户名首字母!',
		pageSize : 5,
		pageList : [ 5, 10 ],
		columns : [ [ {
			title : '编号',
			field : 'userId',
			width : 150,
			hidden : true
		}, {
			title : '工号',
			field : 'username',
			width : 80
		}, {
			title : '用户姓名',
			field : 'userRealName',
			width : 80
		}, {
			title : '所在组ID',
			field : 'groupId',
			width : 100,
			formatter : function(value, row, index) {
				if (value == 0)
					return '';
				return row.groupName;
			}
		}, {
			title : '角色ID',
			field : 'roleId',
			width : 100,
			formatter : function(value, row, index) {
				if (value == 0)
					return '';
				return row.roleName;
			}
		} ] ],
		onLoadSuccess : function(data) {
			if (data.rows.length == 1) {
				$(this).combogrid("grid").datagrid('selectRow', 0);
			}
		}
	});
	
	var rows = $('#moduls_persDuty_datagrid').datagrid('getChecked')[0];
	
	$('#moduls_fun_editPersDuty_editForm input[name=pdId]').val(rows.pdId);
	
	$("#moduls_fun_editPersDuty_editForm #userId").combogrid('setValue', rows.userId);
	$("#moduls_fun_editPersDuty_editForm #userId").combogrid('setText', rows.userRealName);
	
	$.getJSON('persDutyAction!queryByUserId.action', {userId : rows.userId}, function(pduty) {
		editor.insertHtml(pduty.pdCont);
	});
});
</script>
<div align="left">
	<form id="moduls_fun_editPersDuty_editForm" method="post">
		<input type="hidden" name="pdId">
		<table class="tableForm">
			<tr>
			<th style="width: 60px;font-size: 12px; font-weight: normal;">用户姓名：
			<select id="userId" name="userId" data-options="required:true" style="width:150px;"></select></th>
			</tr>
			<tr>
				<th style="width: 60px;font-size: 12px; font-weight: normal;">职责内容：</th>
			</tr>
			<tr>
				<td><textarea name="pdCont" style="width:660px;height:270px;visibility:hidden;"></textarea></td>
			</tr>
		</table>
	</form>
</div>